{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gensim.models import Word2Vec"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['bitcoin', 'is', 'an', 'innovative', 'payment', 'network', 'and', 'a', 'new', 'kind', 'of', 'money.']\n"
     ]
    }
   ],
   "source": [
    "min_count = 0\n",
    "size = 50\n",
    "window = 2\n",
    "sentences= \"bitcoin is an innovative payment network and a new kind of money.\"\n",
    "sentences=sentences.split()\n",
    "print(sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<gensim.models.word2vec.Word2Vec at 0x7fd1d889e710>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = Word2Vec(sentences, min_count=min_count, size=size, window=window)\n",
    "model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([  9.70041566e-03,  -4.16209083e-03,   8.05089157e-03,\n",
       "         4.81479801e-03,   1.93488982e-03,  -4.19071550e-03,\n",
       "         1.41675305e-03,  -6.54719025e-03,   3.92444432e-03,\n",
       "        -7.05081783e-03,   7.69438222e-03,   3.89579940e-03,\n",
       "        -9.02676862e-03,  -8.58401007e-04,  -3.24096601e-03,\n",
       "         9.24982232e-05,   7.13059027e-03,   8.80233292e-03,\n",
       "        -2.46750680e-03,  -5.17094415e-03,   2.74592242e-03,\n",
       "         4.08304436e-03,  -7.59716751e-03,   8.94313212e-03,\n",
       "        -8.39354657e-03,   5.89343486e-03,   3.76902265e-03,\n",
       "         8.84669367e-04,   1.63217512e-04,   8.95449053e-03,\n",
       "        -3.24510527e-03,   3.52341868e-03,   6.98625855e-03,\n",
       "        -5.50296041e-04,  -5.10712992e-03,  -8.52414686e-03,\n",
       "        -3.00202984e-03,  -5.32727176e-03,  -8.02035537e-03,\n",
       "        -9.11156740e-03,  -7.68519414e-04,  -8.95629171e-03,\n",
       "        -1.65163784e-03,   9.59598401e-04,   9.03090648e-03,\n",
       "         5.31166652e-03,   5.59739536e-03,  -4.49402537e-03,\n",
       "        -6.75261812e-03,  -5.75679634e-03], dtype=float32)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model['a']            # Vector for the character 'a'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.00134482, -0.00995359,  0.00704281, -0.00393718, -0.00548969,\n",
       "        0.00916869, -0.00533168,  0.00878989,  0.00731364, -0.00496521,\n",
       "        0.00719894, -0.00961015,  0.00398713, -0.00485147, -0.00313055,\n",
       "        0.00413189, -0.00590664,  0.00899044, -0.00787697,  0.00281024,\n",
       "       -0.00972833,  0.00567152, -0.00541361,  0.0067297 ,  0.0024845 ,\n",
       "       -0.00174522, -0.00226549, -0.00542334,  0.00172413,  0.00457862,\n",
       "       -0.00368878,  0.00697395, -0.00152112,  0.0076662 , -0.00743428,\n",
       "       -0.00941042,  0.00985511, -0.00100739, -0.0078237 , -0.00895459,\n",
       "       -0.00546383, -0.00699405, -0.00584686, -0.00971313, -0.00103236,\n",
       "        0.00535304,  0.00534684,  0.00126653, -0.00048616,  0.00645786], dtype=float32)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model['b']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = gensim.models.KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sentence = [\"I\", \"hope\", \"it\", \"is\", \"going\", \"good\", \"for\", \"you\"]\n",
    "vectors = [model[w] for w in sentence]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
